package cn.sugarscat.order;

import cn.sugarscat.db.DB;

public class PaymentManager {
    public static boolean insertPayment(Payment payment) {
        DB db = new DB();
        boolean ok = false;
        String sql = "INSERT INTO `payment`(" +
                "`order_id`, " +
                "`payment_amount`, " +
                "`payment_type`, " +
                "`payment_time`) VALUES ('" +
                payment.getOrderId() + "', '" +
                payment.getAmount() + "', '" +
                payment.getType() + "', '" +
                payment.getTime() +  "');";
        int num = db.executeInsert(sql);
        if(num>0)
            ok = true;
        db.closeDB();
        return ok;
    }

    public static void deletePayment(int orderId) {
        DB db = new DB();
        String sql = "DELETE FROM `payment` WHERE `order_id` = ?";
        db.executeDelete(sql, ""+orderId);
        db.closeDB();
    }
}
